//
//  CustomNavigationBar.m
//  鼎立华服
//
//  Created by 中企互联 on 2018/1/19.
//  Copyright © 2018年 中企互联. All rights reserved.
//

#import "CustomNavigationBar.h"

@implementation CustomNavigationBar

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        //
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {
    //
    self.BackView = [[UIView alloc] init];
//    self.BackView.backgroundColor = NavBackColor;
    [self addSubview:self.BackView];
    [self.BackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self).with.offset(SYRealValue(0 / 2));
        make.left.equalTo(self).with.offset(SYRealValue(0 / 2));
        make.right.equalTo(self).with.offset(SYRealValue(0 / 2));
        make.top.equalTo(self).with.offset(SYRealValue(0 / 2));
    }];
    //
    //文字
    self.leftBtnTitle = [[UIButton alloc] init];
    self.leftBtnTitle.titleLabel.font = [UIFont boldSystemFontOfSize:72 * px];
    self.leftBtnTitle.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    if ([WRNavigationBar isIphoneX]) {
        self.leftBtnTitle.frame = CGRectMake(0, 45, 250 * px, 30);
    }else{
        self.leftBtnTitle.frame = CGRectMake(0, 30, 250 * px, 30);
        
    }
    [self addSubview:self.leftBtnTitle];
    
    self.leftBtn = [[UIButton alloc]init];
    self.leftBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    if ([WRNavigationBar isIphoneX]) {
        self.leftBtn.frame = CGRectMake(52 * px, 45, 30, 30);
    }else{
    self.leftBtn.frame = CGRectMake(52 * px, 30, 30, 30);
    
    }
    [self addSubview:self.leftBtn];
//    [self.leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.equalTo(self).with.offset(SYRealValue(0 / 2));
//        make.left.equalTo(self).with.offset(SYRealValue(0 / 2));
//        make.size.mas_equalTo(CGSizeMake(SYRealValue(120 / 2), SYRealValue(80 / 2)));
//    }];
    //
    self.rightBtn = [[UIButton alloc]init];
    self.rightBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    if ([WRNavigationBar isIphoneX]) {
        self.rightBtn.frame = CGRectMake(ScreenWidth - 160 * px - 52 * px, 45, 200 * px, 30);
    }else{
        self.rightBtn.frame = CGRectMake(ScreenWidth - 160 * px - 52 * px, 30, 200 * px, 30);
        
    }
    
    //self.rightBtn.backgroundColor = [UIColor redColor];
    //[self.rightBtn setImage:[UIImage imageNamed:@"通用_消息白"] forState:UIControlStateNormal];
    //[self.rightBtn setTitle:@"确定绑卡" forState:UIControlStateNormal];
    [self.rightBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.rightBtn.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(28 / 2)];
    [self addSubview:self.rightBtn];
//    [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.equalTo(self).with.offset(SYRealValue(0 / 2));
//        make.right.equalTo(self).with.offset(- SYRealValue(0 / 2));
//        make.size.mas_equalTo(CGSizeMake(SYRealValue(120 / 2), SYRealValue(80 / 2)));
//    }];
    //
//    self.rightBtnTitle = [[UIButton alloc]init];
//    //self.rightBtnTitle.backgroundColor = [UIColor redColor];
//    //[self.rightBtn setImage:[UIImage imageNamed:@"通用_消息白"] forState:UIControlStateNormal];
//    //[self.rightBtn setTitle:@"确定绑卡" forState:UIControlStateNormal];
//    [self.rightBtnTitle setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//    self.rightBtnTitle.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(32 / 2)];
//    [self addSubview:self.rightBtnTitle];
//    [self.rightBtnTitle mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.equalTo(self).with.offset(SYRealValue(0 / 2));
//        make.right.equalTo(self).with.offset(-SYRealValue(20 / 2));
//        make.size.mas_equalTo(CGSizeMake(SYRealValue(80 / 2), SYRealValue(80 / 2)));
//    }];
    //
    self.titleLabel = [[UILabel alloc]init];
    //self.titleLabel.backgroundColor = [UIColor redColor];
    self.titleLabel.font = [UIFont boldSystemFontOfSize:SYRealValue(38 / 2)];
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self).with.offset(SYRealValue(0 / 2));
        make.centerX.equalTo(self.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(SYRealValue(400 / 2), SYRealValue(80 / 2)));
    }];
    //
    self.bottomLineLayer = [[CALayer alloc] init];
    self.bottomLineLayer.frame = CGRectMake(0, self.bounds.size.height - 0.5, self.bounds.size.width, 0.5);
    self.bottomLineLayer.backgroundColor = NavBackColor.CGColor;
    [self.layer addSublayer:self.bottomLineLayer];
}

@end
